#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtSql>
#include <QSqlDatabase>
#include <QSqlTableModel>
#include <QAbstractItemView>
#include <QTreeView>
#include <QDataWidgetMapper>
#include "calculation.h"



namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    QHash<int, int> Shem;
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    
private:
    Ui::MainWindow *ui;
    QDataWidgetMapper *mapper;
//    QSqlRelationalTableModel *model_main;
    QSqlRelationalTableModel *model_main;
    QSqlTableModel *model_driver;
    QSqlTableModel *model_locomotive;
    QSqlTableModel *model_area;
    QSqlTableModel *model_teh_area;
    QSqlTableModel *model_teh_tip;
    QSqlTableModel *model_one_area;
    QSqlTableModel *model_series;
    QSqlTableModel *model_station;
    calculation pcalc;
    int idArea;
//    QAbstractItemView ItemView;
    void SetAction(void);
    void SetSprav(void);
    void SetRelationModel(void);
    quint32 GetIdFromValue(QString Table, QString Filter);
    int workIdx, stationIdx, areaIdx, locIdx, tehIdx;
    void SetHistory(quint32 Id);
    qint32 GetItemComboBox(QComboBox*, quint32);

private slots:
    void displayGetDriver(QAction*);
//    void display_work_cargo(void);
//    void display_work_manevr(void);
    void gbCargoEnable(void);
    void AddWork(void);
    void DelWork(void);
    void Calc(void);
    void NewTravel(void);
    void Arhive(void);
    void SaveTravel(void);
};

#endif // MAINWINDOW_H
